const event = {
  msg: {},
  add(type, cb){
    if(this.msg[type]){
      this.msg[type].push(cb);
    }else{
      this.msg[type] = [cb];
    }
  },
  remove(type, cb){
    if(!this.msg[type]) return;
    const i = this.msg[type].indexOf(cb);
    if(i !== -1) this.msg[type].splice(i, 1);
  },
  emit(type, data){
    if(!this.msg[type]) return;
    this.msg[type].forEach(val=>{
      val(data);
    })
  }
}